﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace MetMax.BusinessObject
{
    class LibrarySearch : Base
    {
        public IEnumerable<gmdTools.Matching.AnnotatedMatch> gmdMatches { get; set; }

        public LibrarySearch(Base bo, IEnumerable<gmdTools.Matching.AnnotatedMatch> gmdMatches )
            : base(bo)
        {
            this.gmdMatches = gmdMatches;
        }

        public float? bestMatchScore
        {
            get
            {
                if (gmdMatches.Count() == 0)
                {
                    return null;
                }
                return gmdMatches.First().DotproductDistance;
            }
        }

        public float? bestMatchRiDiscrepancy
        {
            get
            {
                if (gmdMatches.Count() == 0)
                {
                    return null;
                }
                return gmdMatches.First().riDiscrepancy;
            }
        }

        public string bestMatchSpectrumName
        {
            get
            {
                if (gmdMatches.Count() == 0)
                {
                    return string.Empty;
                }
                return gmdMatches.First().spectrumName;
            }
        }
        
        public new object ValueNeeded()
        {
            switch (Properties.Settings.Default.myOptions.exportFact)
            {
                case DisplayProperties.bestMatchScore:
                    return bestMatchScore;
                case DisplayProperties.bestMatchRiDiscrepancy:
                    return bestMatchRiDiscrepancy;
                case DisplayProperties.numberMatchingLibrarySpectra:
                    return gmdMatches.Count();
                default:
                    return base.ValueNeeded();
            }
        }
    }
}
